/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package se.sll.service.catalogue.composite.camel.cdi;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import org.apache.camel.cdi.CdiCamelContext;

/**
 *
 * @author khaleddaham
 */
@Singleton
@Startup
@Slf4j
public class Bootstrap {

    @Inject
    CdiCamelContext camelCtx;
    @Inject
    CamelRoute routes;
    public Bootstrap() {
    }

    @PostConstruct
    public void init() {
        log.info("Starting rivta-service-catalogue-v1 camel routes.");
        try {
            camelCtx.addRoutes(routes);
        } catch (Exception ex) {
            log.warn(ex.getMessage(), ex);
        }
        camelCtx.start();
    }

    @PreDestroy
    public void stop() {
        log.info("Stopping rivta-service-catalogue-v1 camel routes.");
        camelCtx.stop();
    }
}